using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class ContactsGroupHeader : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty mStrKeyProperty = DependencyProperty.Register("mStrKey", typeof(string), typeof(ContactsGroupHeader), new PropertyMetadata(null, new PropertyChangedCallback(ContactsGroupHeader.OnmStrKeyPropertyChanged)));
		public static DependencyProperty GroupHeaderKindProperty = DependencyProperty.Register("GroupHeaderKind", typeof(HeaderKind), typeof(ContactsGroupHeader), new PropertyMetadata(HeaderKind.NONE, new PropertyChangedCallback(ContactsGroupHeader.OnGroupHeaderKindPropertyChanged)));
		private bool mBIsBindedVisibility;
		internal Grid btnLayout;
		internal Grid gridContent;
		internal TextBlock textBlock_0;
		internal Image image_0;
		private bool _contentLoaded;
		public event ContactsGroupHeader.ListItemClick ItemClick;
		public string mStrKey
		{
			get
			{
				return (string)base.GetValue(ContactsGroupHeader.mStrKeyProperty);
			}
			set
			{
				base.SetValue(ContactsGroupHeader.mStrKeyProperty, value);
			}
		}
		public HeaderKind GroupHeaderKind
		{
			get
			{
				return (HeaderKind)base.GetValue(ContactsGroupHeader.GroupHeaderKindProperty);
			}
			set
			{
				base.SetValue(ContactsGroupHeader.GroupHeaderKindProperty, value);
			}
		}
		private static void OnmStrKeyPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == ContactsGroupHeader.mStrKeyProperty)
			{
				(dependencyObject_0 as ContactsGroupHeader).mStrKeyPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void mStrKeyPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_OldValue() != dependencyPropertyChangedEventArgs_0.get_NewValue())
			{
				if (string.IsNullOrEmpty(this.mStrKey))
				{
					base.set_Visibility(1);
					return;
				}
				if (this.GroupHeaderKind == HeaderKind.ContactGroup)
				{
					this.bindVisibility();
					char c = this.mStrKey.get_Chars(0);
					if (c == '*')
					{
						this.textBlock_0.set_Visibility(1);
						this.image_0.set_Source(ToolFunction.GetImgFromContentSource("/Resource/Img/Profile/Stared.png"));
						this.image_0.set_Visibility(0);
						return;
					}
					if (c == '&')
					{
						this.textBlock_0.set_Visibility(1);
						this.image_0.set_Source(ToolFunction.GetImgFromContentSource("/Resource/Img/CommonUse/SystemHeadImgs/GroupCardHeader.png"));
						this.image_0.set_Visibility(0);
						return;
					}
					this.image_0.set_Visibility(1);
					this.textBlock_0.set_Visibility(0);
					if (c > '\0' && c <= '\u0013')
					{
						if (ContactsView.GetGroupDisplayStyle() == ContactsGroupStyle.ByStroke)
						{
							this.textBlock_0.set_Text((int)c + "劃");
							this.textBlock_0.set_FontSize(27.0);
							this.textBlock_0.set_Margin(new Thickness(3.0, 0.0, 0.0, 2.0));
						}
						return;
					}
					this.textBlock_0.set_FontSize(48.0);
					this.textBlock_0.set_Margin(new Thickness(10.0, 0.0, 0.0, 2.0));
					this.textBlock_0.set_Text(this.mStrKey);
					return;
				}
				else
				{
					this.textBlock_0.set_FontSize(48.0);
					this.textBlock_0.set_Margin(new Thickness(10.0, 0.0, 0.0, 2.0));
					this.textBlock_0.set_Text(this.mStrKey);
					base.set_Visibility(0);
				}
			}
		}
		private static void OnGroupHeaderKindPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == ContactsGroupHeader.GroupHeaderKindProperty)
			{
				(dependencyObject_0 as ContactsGroupHeader).GroupHeaderKindPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void GroupHeaderKindPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_OldValue() != dependencyPropertyChangedEventArgs_0.get_NewValue() && HeaderKind.ContryList == this.GroupHeaderKind)
			{
				this.bindVisibility();
			}
		}
		public ContactsGroupHeader()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.ContactsGroupHeader_Loaded));
		}
		private void bindVisibility()
		{
			base.set_Visibility(0);
		}
		private void ContactsGroupHeader_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void btnLayout_Click(object sender, object object_0)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.mStrKey);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Contact/ContactsGroupHeader.xaml", 2));
			this.btnLayout = (Grid)base.FindName("btnLayout");
			this.gridContent = (Grid)base.FindName("gridContent");
			this.textBlock_0 = (TextBlock)base.FindName("txt");
			this.image_0 = (Image)base.FindName("img");
		}
	}
}
